﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TracedReality.RayTracing
{
    /// <summary>
    /// A simple representation of a ray.
    /// </summary>
    public class Ray
    {
        /// <summary>
        /// The origin of the ray.
        /// </summary>
        public Vector origin;

        /// <summary>
        /// The direction of the ray.
        /// </summary>
        public Vector direction;

        /// <summary>
        /// Create a Ray with the given origin and direction.
        /// Normalizes the direction.
        /// </summary>
        /// <param name="o">The origin to use.</param>
        /// <param name="d">The direction to use.</param>
        public Ray(Vector o, Vector d) { origin = o; direction = d; direction.normalize(); }

        /// <summary>
        /// Finds the point along this ray with the given parameter.
        /// </summary>
        /// <param name="t">How far along the ray.</param>
        /// <returns>The point on the ray.</returns>
        public Vector pointAtParameter(double t) { return origin + (direction * t); }
    }
}
